// pages/home/index.js
Page({

    /**
     * 页面的初始数据
     */
    data: {
        shop_item: [{
            createTime: "2022-05-18T02:04:17.466Z",
            img_url: ["https://image.jovie.top/img/202203281141269.jpg"],
            info: "",
            title: "计算机网络",
            updateTime: "2022-05-18T02:04:17.466Z",
            value: 20.1,
            _id: "",
            _openid: "",
        }, {
            createTime: "2022-05-18T02:04:17.466Z",
            img_url: ["https://image.jovie.top/img/202203281141269.jpg"],
            info: "",
            title: "计算机网络",
            updateTime: "2022-05-18T02:04:17.466Z",
            value: 20.1,
            _id: "",
            _openid: "",
        }, {
            createTime: "2022-05-18T02:04:17.466Z",
            img_url: ["https://image.jovie.top/img/202203281141269.jpg"],
            info: "",
            title: "计算机网络",
            updateTime: "2022-05-18T02:04:17.466Z",
            value: 20.1,
            _id: "",
            _openid: "",
        }, {
            createTime: "2022-05-18T02:04:17.466Z",
            img_url: ["https://image.jovie.top/img/202203281141269.jpg"],
            info: "",
            title: "计算机网络",
            updateTime: "2022-05-18T02:04:17.466Z",
            value: 20.1,
            _id: "",
            _openid: "",
        }, {
            createTime: "2022-05-18T02:04:17.466Z",
            img_url: ["https://image.jovie.top/img/202203281141269.jpg"],
            info: "",
            title: "计算机网络",
            updateTime: "2022-05-18T02:04:17.466Z",
            value: 20.1,
            _id: "",
            _openid: "",
        }, ]
    },

    /**
     * 生命周期函数--监听页面加载
     */

    getShopItem() {
        let _this = this
        wx.cloud.callFunction({
            name: 'quickstartFunctions',
            config: {
                env: this.data.envId
            },
            data: {
                type: 'getShop'
            }
        }).then((res) => {
            // console.log(res)
            for (let item of res.result.data) {
                if (item.img_url.length == 0) {
                    item.img_url = ["cloud://jovie-yun-9gx8jtve5e89b724.6a6f-jovie-yun-9gx8jtve5e89b724-1305044671/no_picture.png"]
                }
            }
            _this.setData({
                shop_item: res.result.data
            })
            // console.log(_this.data.shop_item)
        })
    },

    onLoad: function (options) {
        this.getShopItem()
    },

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function () {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function () {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function () {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function () {
        this.getShopItem()
    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function () {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function () {

    }
})